package com.etc.controller;

import com.etc.entity.SysLog;
import com.etc.entity.SysOrder;
import com.etc.service.SysLogService;
import com.etc.service.SysOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.List;


/**
 * 日志控制器
 * @author Administrator
 *
 */
@Controller
@RequestMapping("log")
public class SysLogController {
	
	@Autowired
	private SysLogService sysservice;

	@Autowired
	private SysOrderService sysOrderService;

	@RequestMapping("log")
	public String log (HttpServletRequest request) throws ParseException {
		request.setAttribute("orderconet",sysOrderService.findByweiOrder().size());
		List<SysOrder> sysOrders1 = sysservice.getTurnover();//营业额
		List<SysOrder> sysOrders2 =sysservice.finsh();//今天完成订单
		List<SysOrder> sysOrders3 =sysservice.getOrder();//今天的订单
		List<SysOrder> sysOrders4 =sysservice.getdfd();//未处理

		request.setAttribute("Today",sysOrders3);
		request.setAttribute("success",sysOrders2);
		request.setAttribute("Untreated",sysOrders4);
		request.setAttribute("Turnover",sysOrders1);
		Double number = 0.0;
		for(SysOrder sysOrder:sysOrders1){
			number = number+Double.valueOf(sysOrder.getPayment());
		}
		request.setAttribute("Today1",sysOrders3.size());
		request.setAttribute("success2",sysOrders2.size());
		request.setAttribute("Untreated3",sysOrders4.size());
		request.setAttribute("Turnover4",String.valueOf(number));

		return "log";
	}
	
	


}
